package com.shangze.test.presenter.fragment;

import android.content.Context;
import com.shangze.test.app.UserInfo;
import com.shangze.test.base.BasePresenter;
import com.shangze.test.bean.FriendBean;
import com.shangze.test.net.RxHelper;
import com.shangze.test.net.RxSubscribe;
import com.shangze.test.presenter_view.ArrayView;

import java.util.List;


/**
 * Created by yjm on 2017/10/19.
 */

public class CircleFriendsPresenter extends BasePresenter<ArrayView> {


    @Override
    public void attachView(ArrayView mvpView) {
        super.attachView(mvpView);
    }

    public void getFriends(Context cxt) {
        apiStores.getFriends(UserInfo.getUserId())
                .compose(RxHelper.<List<FriendBean>>handleResult())
                .subscribe(new RxSubscribe<List<FriendBean>>(cxt, false) {
                    @Override
                    protected void _onNext(List<FriendBean> data) {
                        //这里保存好友数据到数据库。。。。
                        view.addNews(data, 0);
                    }

                    @Override
                    protected void _onError(String message) {
                    }
                });
    }
}
